﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace 字典1
{
    class Program
    {
        static void Main(string[] args)
        {
            //<键的类型,值的类型>
            Dictionary<string, int> dict = new Dictionary<string, int>();
            dict.Add("0108888888888", 30);//放进去一个键值对
            dict.Add("1108889998x", 18);
            dict.Add("0108888889999", 22);
            dict.Add("010888888x", 18);//如果添加相同key的项会报错

            //dict.Add("010888888x",19);
            //用索引的方式赋值相当于存在就update，不存在就insert
            //和Add相比，这种方式不会报错
            dict["010888888x"] = 19;
            dict["010888888y"] = 19;

            int age = dict["0108888888888"];//按照key找value
            Console.WriteLine(age);

           // dict.Remove("010888888x");//移除指定key的值

            //dict.Clear();
            //Console.WriteLine(dict.ContainsKey("0108888888888"));
            //Console.WriteLine(dict.ContainsKey("afdasfasdfdsa"));
            //判断是否存在key

            foreach (string key in dict.Keys)
            {
                int value = dict[key];//select * from ...where id=@Id
                Console.WriteLine("{0}={1}", key, value);
            }


            Console.ReadKey();
        }
    }
}
